<?php
namespace Admin\Controller;
class DemoController extends IsloginController{
	function add(){
		$sty = M("Style");
		$arr = $sty->select();
		$this->assign('arr',$arr);
		$this->display();
	}
	function save(){
			$upload= new \Think\Upload();
			$upload->autoSub  =false;
			$upload->mimes=array('image/png',"image/gif","image/jpeg");
			$upload->rootPath = './Public';
       		$upload->savePath = '/Upload/';
			$info=$upload->upload();
			if($info){
			$_POST['imagename']=$info['imagename']['savename'];
			}
			$product=M("List");		
			$_POST['addtime']=time();
			$re=$product->data($_POST)->save();
			if($re){
				$this->success("图片添加成功",U("Demo/oper"));
			}else{
				$this->error("图片添加失败",U("Demo/add"));
			}
	}
		/*$demo = M("Demoname");
		$_POST['addtime']=time();
		$re = $demo->data($_POST)->add();
		var_dump($_POST);
		if($re){
			$upload= new \Think\Upload();
			$upload->autoSub  =false;
			$upload->mimes=array('image/png',"image/gif","image/jpeg");
			$upload->rootPath = './Public';
       		$upload->savePath = '/Upload/';
			$info=$upload->upload();
			if($info){
			$_POST['imagename']=$info['imagename']['savename'];
			}
			$product=M("Demoimage");
			$id=$_POST['id'];
			$_POST['fid']=$id;
			var_dump($id);
			$_POST['addtime']=time();
			$re=$product->data($_POST)->add();
			if($re){
				$this->success("图片添加成功",100);
			}else{
				$this->error("图片添加失败",100);
			}
		}*/
		
	function chaxun(){
		$demo = M("List");
		$arr = $demo->where("area<60" or "area>60 && area<80" or "area>80 && area<100" or "area>100 && area<120" or "area>120 && area<150" or  "area>150")->select();
		if($arr){
			$this->success("查询成功",U("Demo/oper"));
		}else{
			$this->error("查询失败",U("Demo/oper"));
		}
	}
	function del(){
		$shanchu = M("List");
		$id=$_POST['id'];
		$re =$shanchu->where("id=$id")->delete();
		if($re){
			$this->success("删除成功",U("Demo/oper"));
		}else{
			$this->error("删除失败",U("Demo/oper"));
		}
	}
	function oper(){
		$op = M("List");
		$num=$op->count();
// 		3、规定每页显示的条数
		$pageSize=8;
// 		4、实例化分页类
		$pageOb=new \Think\Page($num,$pageSize);
// 		5、获取开始位置值
		$start=$pageOb->firstRow;
// 		6、获取分页结果
		$pageStr=$pageOb->show();
		$arr = $op->limit("$start,$pageSize")->select();
		if($arr){
			$this->assign('pageStr',$pageStr);
			$this->assign('arr',$arr);
		}else{
			
		}
		$this->show();
	}
	function update(){
		$up = M("List");
		$id=$_GET["id"];
		$arr = $up->where("id=$id")->find();
		$this->assign('arr',$arr);
		$this->display();
	}





}